<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #log {
      width: 400px;
      min-height: 100px;
      color: white;
      background-color: red;
      padding: 10px;
    }
  </style>
</head>

<body>
  <script src="../hulog/index.js"></script>
  <!-- <div id="log"></div> -->
  <script>
    const log = (new hulog()).log;
    // const log = hulog().log;
    const timer = () => new Promise((resolve, reject) => {
      setTimeout(() => {
        log("timer")
        resolve("timer done");
      }, 1000);
    });
    const timer1 = () => new Promise((resolve, reject) => {
      setTimeout(() => {
        log("timer1")
        resolve("timer1 done ");
      }, 2000);
    });
    const timer2 = () => new Promise((resolve, reject) => {
      setTimeout(() => {
        log("timer2")
        resolve();
      }, 1000);
    });
    const timer3 = () => new Promise((resolve, reject) => {
      setTimeout(() => {
        log("timer3")
        resolve();
      }, 1000);
    });
    // const generatorAction = function* () {
    function* generatorAction() {
      yield timer();
      yield timer1();
      yield timer2();
      yield timer3();
    }


    const action = generatorAction();
    const tim = action.next();
    tim.value.then((result) => {
      for (let index = 0; index < 1000; index++) {
        hulog(result);

      }
      action.next();
    }).catch((err) => {

    });
    // hulog(action.next())

  </script>
</body>

</html>